<extend name="Public/publicHTML" />

<block name='content'>
<link href="__COMMON__/daterangepicker/daterangepicker-bs3.css"
	rel="stylesheet" type="text/css" />
<script src="__COMMON__/daterangepicker/moment.min.js"
	type="text/javascript"></script> <script
	src="__COMMON__/daterangepicker/daterangepicker.js"
	type="text/javascript"></script>
<link rel="stylesheet" href="__COMMON__/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet"
	href="__COMMON__/bootstrap/css/font-awesome.min.css" />
	<script src="__COMMON__/js/Ueditor/ueditor.config.js"></script>
	<script src="__COMMON__/js/Ueditor/ueditor.all.min.js"> </script>
	<script src="__COMMON__/js/Ueditor/lang/zh-cn/zh-cn.js"></script>
<div class="wrapper">
<section class="content ">
	<!-- Main content -->
	<div class="container-fluid">
		<div class="pull-right">
			<a href="javascript:history.go(-1)" data-toggle="tooltip" title=""
				class="btn btn-default" data-original-title="返回"><i
				class="fa fa-reply"></i></a> 
		</div>
		<div class="panel panel-default">
			<div class="panel-heading">
				<h3 class="panel-title">
					<i class="fa fa-list"></i> 添加商品促销活动
				</h3>
			</div>
			<div class="panel-body ">
				<!--表单数据-->
				<form method="post" id="promotion">
					<!--通用信息-->
					<div class="tab-content col-md-10">
						<div class="tab-pane active" id="tab_tongyong">
							<table class="table table-bordered">
								<tbody>
								<tr>
									<td class="col-sm-2">选择赠品功能类型：</td>
									<td class="col-xs-8">
										<select name="type" id="select_change_style" class="form-control w150">
										{$row_data.type_status}
										</select></td>
								</tr>
								<tr id="money_style_status">
									<td>满赠价格：</td>
									<td><input type="text" class="form-control w300" name="expression" value="{$row_data.expression}">
									</td>

								</tr>
									<tr  id="tr_style_status">
										<td class="col-sm-2">商品名称：</td>
										<td>
											<div class="form-group">
												<div class="col-xs-2">
													<a class="btn btn-primary" href="javascript:void(0);"
													   onclick="Promation.selectRowGoods('{:U('searchRowGoods')}')"><i class="fa fa-search"></i>添加商品</a>
												</div>
												<div class="col-xs-2">
													<span id="err_goods" style="color: #F00; display: none;">请添加下单商品</span>
												</div>
											</div>
										</td>
									</tr>
									<tr>
										<td>开始时间：</td>
										<td><input type="text" class="form-control w300"
											id="start_time" name="start_time" value="{$row_data.start_time|date='Y-m-d H:m:s',###}">
										</td>

									</tr>
									<tr>
										<td>结束时间：</td>
										<td><input type="text" class="form-control w300" id="end_time"
											name="end_time" value="{$row_data.end_time|date='Y-m-d H:m:s',###}"></td>
									</tr>
									<tr>
										<td>适合用户范围：</td>
										<td>
											{$user_level_html}
										</td>
									</tr>
									<tr>
										<td>选择赠品:</td>
										<td>
											<div class="form-group">
												<div class="col-xs-2">
													<a class="btn btn-primary" href="javascript:void(0);"
													   onclick="Promation.selectGifts('{:U('searchGifts')}')"><i class="fa fa-search"></i>添加赠品</a>
												</div>
												<div class="col-xs-2">
													<span id="err_goods" style="color: #F00; display: none;">请添加下单商品</span>
												</div>
											</div>
										</td>
									</tr>
									<tr>
										<td colspan="2">
											<div class="form-group">
												<table class="table table-bordered goods_style_status">
													<thead>
														<tr>
															<th style="display: none">选择</th>
															<th class="text-left">商品名称</th>
															<th class="text-left">价格</th>
															<th class="text-left">库存</th>
															<th class="text-left">操作</th>
														</tr>
													</thead>
													<input type="hidden" name="gift_id" value="{$row_data.id}">
													<tbody id="goods_list">
													{$good_html}
													</tbody>
												</table>
												<table class="table table-bordered">
													<thead>
													<tr>
														<th style="display: none">选择</th>
														<th class="text-left">赠品名称</th>
														<th class="text-left">赠品数量</th>
														<th class="text-left">赠品库存</th>
														<th class="text-left">操作</th>
													</tr>
													</thead>
													<tbody id="gifts_list">
													{$gift_html}
													</tbody>
												</table>
											</div>
										</td>
									</tr>
									<tr>
										<td class="col-sm-2">活动描述：</td>
										<td class="col-sm-8"><textarea class="span12 ckeditor"
												id="post_content" name="description" title="">
							        {$row_data.description}
							        </textarea></td>
									</tr>
								</tbody>
								<tfoot>
									<tr>
										<td><input class="btn btn-default" type="reset"
											value="重置"></td>
										<td class="text-right"><input class="btn btn-primary"
											type="button" onclick="Promation.addPromation('promotion', '{:U('saveGift')}')" value="保存"></td>
									</tr>
								</tfoot>
							</table>
						</div>
					</div>
				</form>
				<!--表单数据-->
			</div>
		</div>
	</div>
</section>
</div>
	<script>
		$(document).ready(function() {
			$('#tr_style_status').css('display','none');
			$('.goods_style_status').css('display','none');
			$('#money_style_status').css('display','table-row');
			if ($('#select_change_style').children('option:selected').val() == 0) {
				$('#money_style_status').css('display','table-row');
				$('#tr_style_status').css('display','none');
				$('.goods_style_status').css('display','none');
			}else{
				$('#tr_style_status').css('display','table-row');
				$('.goods_style_status').css('display','table');
				$('#money_style_status').css('display','none');
			}
			$('#select_change_style').change(function(){
				if ($(this).children('option:selected').val() == 0) {
					$('#money_style_status').css('display','table-row');
					$('#tr_style_status').css('display','none');
					$('.goods_style_status').css('display','none');
				}else{
					$('#tr_style_status').css('display','table-row');
					$('.goods_style_status').css('display','table');
					$('#money_style_status').css('display','none');
				}
			})
			$(".ajax_deleted").click(function(){
				var id=$(this).attr('value');
				$(this).parent().parent().remove();
				$.ajax({
					type: "POST",
					url: "{:U('Promotion/ajaxDeleted')}",
					data: "id="+id,
					success: function(data){
						if(data['data']==1){
						}
					}
				});
			})
		})
	</script>
<script type="text/javascript" src="__COMMON__/js/jquery-form.js"></script>
 <script type="text/javascript" src="__COMMON__/js/alert.js?a={:time()}"></script> 
<script type="text/javascript" src="__JS__/goods/ueditor.config.js"></script> 
<script type="text/javascript" src="__JS__/promation/promation.js?a={:time()}"></script> 
</block>